package com.nbsaas.boot.vipcard.rest.convert;

import com.nbsaas.boot.vipcard.data.entity.VipCard;
import com.nbsaas.boot.vipcard.api.domain.response.VipCardResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* -实体对象转化成响应对象
*/

public class VipCardResponseConvert  implements Converter<VipCardResponse,VipCard> {

    @Override
    public VipCardResponse convert(VipCard source) {
        VipCardResponse  result = new  VipCardResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getOwner()!=null){
                        result.setOwner(source.getOwner().getId());
                    }

                    try {
                        if(source.getCard()!=null){
                            result.setCardName(source.getCard().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getOwner()!=null){
                            result.setOwnerName(source.getOwner().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getCard()!=null){
                        result.setCard(source.getCard().getId());
                    }
        return result;
    }

}

